package kr.hkit.androidcomplete02.ch19;

import kr.hyunist.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class LongTime2Ex extends Activity {
	int mValue;
	TextView mText;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch19_upload);
		
		mText  = (TextView) findViewById(R.id.ch19_uploadtv);
	}
	
	Handler mHandler = new Handler(){

		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			if(msg.what == 0){
				mValue++;
				mText.setText(Integer.toString(mValue));
				try {
					Thread.sleep(50);
				} catch (InterruptedException e) {
					
				}
				
				if(mValue < 100){
					mHandler.sendEmptyMessage(0);
				}
			}
			
		}
		
	};
	public void mOnClick(View v){
		mValue = 0;
		mHandler.sendEmptyMessage(0);
	}

}
